home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE06 / VBX / SWITCH.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-01-02  |  3.6 KB  |  127 lines

  1. {********************************************}
  2. {*                                          *}
  3. {*  SWITCH.PAS generated from SWITCH.VBX    *}
  4. {*                                          *}
  5. {********************************************}
  6.  
  7. unit Switch;
  8.  
  9. interface
  10.  
  11. uses SysUtils, Classes, Graphics, Forms, Controls, VBXCtrl, BIVBX;
  12.  
  13. { $DEFINE InitTBiSwitch}
  14. {^- Remove space to enable default init data -- See documentation. }
  15.  
  16. type
  17.   TBiSwitchOnEvent = procedure (Sender: TObject) of object;
  18.   TBiSwitchOffEvent = procedure (Sender: TObject) of object;
  19.  
  20.   { TBiSwitch }
  21.  
  22.   TBiSwitch = class(TVBXControl)
  23.   protected
  24.     FOnOn: TBiSwitchOnEvent;
  25.     FOnOff: TBiSwitchOffEvent;
  26.     { Event handler }
  27.     procedure HandleVBXEvent(var Message: TWMVBXFireEvent); override;
  28.   public
  29.     constructor Create(AOwner: TComponent); override;
  30.  
  31.     property Index: TVBInteger index 1 read GetIntProp;
  32.   published
  33.     property Visible;
  34.     property ForeColor: TColor index 10 read GetColorProp write SetColorProp
  35.       default -2147483640;
  36.     property BackColor: TColor index 11 read GetColorProp write SetColorProp
  37.       default -2147483633;
  38.     property Caption;
  39.     property BorderStyle: TVBEnum index 13 read GetEnumProp write SetEnumProp
  40.       default 0;
  41.     property pOn: Boolean index 14 read GetBoolProp write SetBoolProp;
  42.     property TextPosition: TVBEnum index 15 read GetEnumProp write
  43.       SetEnumProp default 0;
  44.     property Font;
  45.     property ParentFont;
  46.     property TabStop;
  47.     property TabOrder;
  48.     property DragMode;
  49.     property DragCursor;
  50.     property OnOn: TBiSwitchOnEvent read FOnOn write FOnOn;
  51.     property OnOff: TBiSwitchOffEvent read FOnOff write FOnOff;
  52.     property OnMouseMove;
  53.     property OnMouseDown;
  54.     property OnMouseUp;
  55.     property OnKeyDown;
  56.     property OnKeyUp;
  57.     property OnKeyPress;
  58.     property OnEnter;
  59.     property OnExit;
  60.     property OnDragOver;
  61.     property OnDragDrop;
  62.     property OnEndDrag;
  63.   end;
  64.  
  65. procedure Register;
  66.  
  67. implementation
  68.  
  69. { Default form data for TBiSwitch }
  70.  
  71. {$IFDEF InitTBiSwitch}
  72.  
  73. const
  74.   TBiSwitchInitLen = 57;
  75.  
  76. procedure TBiSwitchInitData; near; assembler;
  77. asm
  78.     DB    $00,$08,$42,$69,$53,$77,$69,$74,$63,$68,$01,$00,$00,$02,$06,$FF
  79.     DB    $FF,$08,$00,$0A,$00,$00,$00,$00,$0B,$0F,$00,$00,$80,$0C,$08,$42
  80.     DB    $49,$53,$57,$49,$54,$43,$48,$0D,$00,$0E,$00,$00,$0F,$00,$10,$00
  81.     DB    $16,$00,$00,$17,$00,$00,$18,$00,$FF
  82. end;
  83.  
  84. {$ENDIF}
  85.  
  86. { TBiSwitch }
  87.  
  88. constructor TBiSwitch.Create(AOwner: TComponent);
  89. begin
  90.   FVBXFile := StrNew('SWITCH.VBX');
  91.   FVBXClass := StrNew('BISWITCH');
  92.   SetBounds(0, 0, 80, 32);
  93.   inherited Create(AOwner);
  94.   ControlStyle := ControlStyle - [csCaptureMouse, csClickEvents];
  95.   TabStop := True;
  96.   FVBXFlags := [vfProcessMnemonic];
  97.   {$IFDEF InitTBiSwitch}
  98.   FHForm := VBXCreateFormFile(TBiSwitchInitLen, @TBiSwitchInitData);
  99.   {$ENDIF}
  100. end;
  101.  
  102. procedure TBiSwitch.HandleVBXEvent(var Message: TWMVBXFireEvent);
  103. begin
  104.   case Message.VBXEvent^.EventIndex of
  105.     0: DispatchCustomEvent(FOnOn, Message, 0);
  106.     1: DispatchCustomEvent(FOnOff, Message, 1);
  107.     2: DispatchMouseMoveEvent(OnMouseMove, Message);
  108.     3: DispatchMouseEvent(OnMouseDown, Message);
  109.     4: DispatchMouseEvent(OnMouseUp, Message);
  110.     5: DispatchKeyEvent(OnKeyDown, Message);
  111.     6: DispatchKeyEvent(OnKeyUp, Message);
  112.     7: DispatchKeyPressedEvent(OnKeyPress, Message);
  113.     8: begin end; { VCL Handles OnGotFocus }
  114.     9: begin end; { VCL Handles OnLostFocus }
  115.     10: begin end; { VCL Handles OnDragOver }
  116.     11: begin end; { VCL Handles OnDragDrop }
  117.   end;
  118. end;
  119.  
  120. { Designer registration }
  121. procedure Register;
  122. begin
  123.   RegisterComponents('VBX', [TBiSwitch]);
  124. end;
  125.  
  126. end.
  127.